package firing;

import firing.Node;

public abstract class AbstractUnaryNode implements UnaryNode {

    private static final long serialVersionUID = 1101695270101013201L;
    protected Node child;
    
    public AbstractUnaryNode() {
	randomizeNode();
    }
    
    @Override
    public Node getChild() {
	return child;
    }

    @Override
    public void setChild(Node child) {
	this.child = child;
    }

    public boolean isUnaryNode() {
	return true;
    }
    
    public String printNode(int depth) {
	StringBuilder sb = new StringBuilder();
	for(int i=0;i<depth;i++) {
	    sb.append("-  ");
	}
	sb.append(toString());
	sb.append('\n');
	if (child != null) {
	    sb.append(child.printNode(depth + 1));
	}
	return sb.toString();
    }
}
